-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merging [time.zone]
, [time.clock]
, and [time.parse]
pieces of P0355R7
#1789
Merging [time.zone]
, [time.clock]
, and [time.parse]
pieces of P0355R7
#1789
Conversation
feature/chrono: Merge toolset update
* [time.clocks] C++20 clocks * concepts workarounds for /BE * test failures and review feedback * buildfix * fix _HAS_CXX20/namespace nesting * _File_time_clock to filesystem namespace * [time.clock.file] tests now pass, consolidate testing code * revert whitespace change; more review feedback * utc_clock::to_sys with floating point durations * Unicode Windows API functions * YOU get constexpr, YOU get constexpr, EVERYBODY gets constexpr * Comment cleanup * SHOUTY comments: in for a penny, in for a pound * formatting * static_assert wording * improved exception handling * switch negated test * less macro-y alias * explicit return types to match Standard * renames and noexcept * misc review feedback * clang-format * addressing review comments on test coverage Co-authored-by: Miya Natsuhara <[email protected]>
* Loading time_zone names from icu.dll * formatting * Addressed feedback and fixed tests. * Removed manual link map and altered tests. * 121 chars in test script hacks :( * Try again with tests * Test should run now * I think my previous changes got flagged? * Trying to get output from tests. * Win10 20H2 VMSS. * Reverted CI test hacks * Feedback and error handling. * Version, error handling and feedback * More feedback * Remove qualifiers from test Co-authored-by: mnatsuhara <[email protected]> Co-authored-by: Stephan T. Lavavej <[email protected]> Co-authored-by: mnatsuhara <[email protected]>
* Initial draft * Addressed feedback * Final feedback
Co-authored-by: Stephan T. Lavavej <[email protected]>
Co-authored-by: Stephan T. Lavavej <[email protected]>
Co-authored-by: Stephan T. Lavavej <[email protected]>
[time.zone]
and [time.clock]
pieces of P0355R7[time.zone]
, [time.clock]
, and [time.parse]
pieces of P0355R7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just noticed some memory leaks and minor nitpicks. I'll push fixes.
tests/std/tests/P0355R7_calendars_and_time_zones_clocks/test.cpp
Outdated
Show resolved
Hide resolved
* Remove extra space in comment. * Consistently _CHRONO qualify "near-shadowing". * Remove now() strengthening; utc_clock::now() isn't strengthened. * Cite WP number.
I pushed the following changes:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My hat is for for that incredible work. I will happily remember to not do any chrono related stuff.
I found some nits. Generally I really prefer to delete special members rather than defaulting the other ones.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: MattStephanson <[email protected]>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None of these comments relates to correctness. I'm fine with making changes now or filing a followup issue "Address Casey's comments on GH-1789," so I'm approving.
void deallocate(_Ty* const _Ptr, size_t) noexcept { | ||
__std_free_crt(_Ptr); | ||
} | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm disturbed by having a _Meow_allocator
type in product code that doesn't satisfy the allocator requirements. It might be overkill to actually implement template <class _Ty1, class _Ty2> bool operator==(const _Crt_allocator<_Ty1>&, const _Crt_allocator<_Ty2>&)
, however - could we at least have a comment to the effect that this isn't really an allocator because ==
is missing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd prefer to have a properly implemented ==
(as product code should hold itself to a high standard), even though we aren't actually using it yet.
// CLASS time_zone | ||
class time_zone { | ||
public: | ||
explicit time_zone(string_view _Name_) : _Name(_Name_) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make this constructor which never emits exceptions noexcept
? (Note that this wouldn't be a strengthening since this constructor is unspecified.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Speaking of unspecified, should this constructor (and all similar unspecified constructors for other types) have a first parameter with an internal type so users cannot accidentally (or intentionally) construct one from a string_view
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for both. Upon looking at this again, the potential for users to write time_zone tz{"PDT"};
is dangerously high.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Upon looking at this again, the potential for users to write
time_zone tz{"PDT"};
is dangerously high.
Yes, it would be nice to make it easier for users to avoid accidentally (or intentionally) using a non-portable initialization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that the data member we're constructing is string _Name;
, so noexcept
would be unwise here.
// CLASS time_zone_link | ||
class time_zone_link { | ||
public: | ||
explicit time_zone_link(string_view _Name_, string_view _Target_) : _Name(_Name_), _Target(_Target_) {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto "Should we noexcept
?"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto nope, we're constructing string _Name;
and string _Target;
.
We can tag this constructor, though.
_Xruntime_error("Internal error loading IANA database information"); | ||
} | ||
|
||
return {_Info->_Tz_name}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this usage is correct, brace-init of a type with an initializer_list
constructor (or a type that potentially has such a constructor) when we don't intend to invoke that initializer_list
constructor is a code smell. Could we just return _Info->_Tz_name;
here so every future reader doesn't have to verify that this is ok?
|
||
template <class _DurationType> | ||
_NODISCARD bool _Make_time_point(_DurationType& _Dur, _LeapSecondRep _Leap) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (_Leap != _LeapSecondRep::_None) { | ||
if (_Hour_24 == 23 && _Minute == 59 && _Second >= 59) { | ||
// It's possible that the parsed time doesn't exist because (a) _Seconds == 60 and there *isn't* a | ||
// leap second insertion or (b) _Seconds == 59 and there *is* a leap second subtraction. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 4133 refers to negative leap second "deletion"; we should consistently use the same term throughout this file. I have no strong feelings, but note that "deletion" is more obviously an antonym of "insertion".
_NODISCARD _InIt _Parse_time_field(_InIt _First, ios_base& _Iosbase, ios_base::iostate& _State, | ||
const char _Flag, const char _Modifier, const unsigned int _Width, | ||
const unsigned int _Subsecond_precision) { | ||
using _CharT = typename _InIt::value_type; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not correct if _InIt
is a generic input iterator. It should use iterator_traits
to retrieve the corresponding value type, or better yet the shortcut alias _Iter_value_t<_InIt>
. If it's not a generic input iterator, we should change the name to avoid our convention that _InIt
means "input iterator." It looks like these only need to work with istream_iterator
s; If that's the case, just plain _Iter
will work. (Several occurrences.)
|
||
const auto& _Ctype_fac = _STD use_facet<ctype<_CharT>>(_Iosbase.getloc()); | ||
const auto& _Time_fac = _STD use_facet<time_get<_CharT>>(_Iosbase.getloc()); | ||
constexpr _InIt _Last{}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cpp17InputIterator
does not require default construction - let alone constexpr
default construction - so this is plain wrong if _InIt
is meant to be a generic input iterator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's always an istreambuf_iterator
; I'll make the code accordingly specific so this will be obviously correct.
Thanks @mnatsuhara, @d-winsor, and @MattStephanson for these major pieces of |
⌚ ⌛ 🗺️
Partially addresses #12
This merges
feature/chrono
intomain
as[time.zone]
,[time.clock]
, and[time.parse]
have been implemented, leaving no partially-finished pieces except for formatting (see Extensions to<chrono>
).Thanks to @d-winsor, @MattStephanson, and @StephanTLavavej for all of their hard work!